<!DOCTYPE html>
<html lang="zh">
	<head>
		<meta charset="UTF-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>主页示例</title>
		<script type="text/javascript" src="js/xhr.js"></script>
		<script type="text/javascript">
			function init() {
				refresh();
			}

			function refresh() {
				//这里是请求协议，需要根据双方约定来
				var post_req = {
					"type": 1,
					"limit": "all"
				};

				XHR.post('cgi-bin/web.cgi', JSON.stringify(post_req),
					function(x, info) {
						console.log(info);
						if (info.result != 0) {
							alert("get data err");
						}
					}
					
				);
			}
			//console.log("%s\n",JSON.stringify(post_req))
			//console.log('data = ', info.data[i].val)
			
			if(info.data[i].key == 1)
			{
				document.getElementById('temp').value = info.data[i].val;
			}
			else if(info.data[i].key == 2)
			{
				document.getElementById('hum').value = info.data[i].val;
			}
			else if(info.data[i].key == 3)
			{
				document.getElementById('ill').value = info.data[i].val;
			}
		</script>
	</head>
	<body onload="init()">
		<a href="index.html">主页</a>
		<br>
		<a href="temp_modbus.html">modbus示例页面</a>
		
	</br>
	</body>
</html>
